package com.fnzn.entranceGuard.service.power.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.fnzn.entranceGuard.entity.power.PowerDevice;
import com.fnzn.entranceGuard.mapper.power.PowerDeviceMapper;
import com.fnzn.entranceGuard.service.power.IPowerDeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author sxf
 * @since 2019-01-09
 */
@Service
public class PowerDeviceServiceImpl extends ServiceImpl<PowerDeviceMapper, PowerDevice> implements IPowerDeviceService {
    @Autowired
    private PowerDeviceMapper deviceMapper;

    @Override
    public PowerDevice getPowerById(String deviceId, String powerId) {
        Wrapper wrapper = new EntityWrapper();
        wrapper.eq("device_id",deviceId);
        wrapper.eq("power_id",powerId);
        List<PowerDevice> list = deviceMapper.selectList(wrapper);
        if(list!=null && !list.isEmpty()){
            return list.get(0);
        }
        return null;
    }

    @Override
    public List getPowerById(String deviceId) {
        Wrapper wrapper = new EntityWrapper();
        wrapper.eq("device_id",deviceId);
        return  deviceMapper.selectList(wrapper);
    }
}
